/*
 Navicat MySQL Data Transfer

 Source Server         : mysql8.0
 Source Server Type    : MySQL
 Source Server Version : 80035
 Source Host           : 192.168.67.5:3306
 Source Schema         : study_management

 Target Server Type    : MySQL
 Target Server Version : 80035
 File Encoding         : 65001

 Date: 25/10/2025 20:08:14
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for course_enrollments
-- ----------------------------
DROP TABLE IF EXISTS `course_enrollments`;
CREATE TABLE `course_enrollments` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `created_at` datetime(6) DEFAULT NULL,
  `status` enum('APPROVED','PENDING','REJECTED') DEFAULT NULL,
  `updated_at` datetime(6) DEFAULT NULL,
  `course_id` bigint DEFAULT NULL,
  `user_id` bigint DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FKd2ko0vfuvwrlv0h8b4et9gkn0` (`course_id`),
  KEY `FK8crk7kl1wekpkmd4kyilc8aw9` (`user_id`),
  CONSTRAINT `FK8crk7kl1wekpkmd4kyilc8aw9` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`),
  CONSTRAINT `FKd2ko0vfuvwrlv0h8b4et9gkn0` FOREIGN KEY (`course_id`) REFERENCES `study_course` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for course_tags
-- ----------------------------
DROP TABLE IF EXISTS `course_tags`;
CREATE TABLE `course_tags` (
  `course_id` bigint NOT NULL,
  `tag` varchar(255) DEFAULT NULL,
  KEY `FKfsk947wqb65reqnxk0hcf9o0n` (`course_id`),
  CONSTRAINT `FKfsk947wqb65reqnxk0hcf9o0n` FOREIGN KEY (`course_id`) REFERENCES `study_course` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for operation_log
-- ----------------------------
DROP TABLE IF EXISTS `operation_log`;
CREATE TABLE `operation_log` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `description` varchar(1000) DEFAULT NULL,
  `ip_address` varchar(255) DEFAULT NULL,
  `module` varchar(255) NOT NULL,
  `operation_type` varchar(255) NOT NULL,
  `request_params` varchar(2000) DEFAULT NULL,
  `timestamp` datetime(6) NOT NULL,
  `user_agent` varchar(1000) DEFAULT NULL,
  `username` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of operation_log
-- ----------------------------
BEGIN;
INSERT INTO `operation_log` VALUES (141, '用户登录', '0:0:0:0:0:0:0:1', '认证系统', 'LOGIN', '[LoginRequest(username=admin, password=admin123)]', '2025-10-25 20:05:05.889287', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'anonymous');
COMMIT;

-- ----------------------------
-- Table structure for study_answer
-- ----------------------------
DROP TABLE IF EXISTS `study_answer`;
CREATE TABLE `study_answer` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `content` varchar(5000) DEFAULT NULL,
  `create_time` datetime(6) DEFAULT NULL,
  `dislike_count` int DEFAULT NULL,
  `is_accepted` bit(1) DEFAULT NULL,
  `like_count` int DEFAULT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `question_id` bigint NOT NULL,
  `user_id` bigint NOT NULL,
  `parent_answer_id` bigint DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FKf7xon0d02sfndr3kqc1vi4odf` (`question_id`),
  KEY `FKde3s500u53dx9jo1bkb65s71a` (`user_id`),
  KEY `FK3asag74agkd82688vbyl0ch0y` (`parent_answer_id`),
  CONSTRAINT `FK3asag74agkd82688vbyl0ch0y` FOREIGN KEY (`parent_answer_id`) REFERENCES `study_answer` (`id`),
  CONSTRAINT `FKde3s500u53dx9jo1bkb65s71a` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`),
  CONSTRAINT `FKf7xon0d02sfndr3kqc1vi4odf` FOREIGN KEY (`question_id`) REFERENCES `study_question` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of study_answer
-- ----------------------------
BEGIN;
INSERT INTO `study_answer` VALUES (1, '哈哈哈', '2025-09-24 09:58:34.918054', 0, b'0', 1, '2025-10-10 09:44:42.020439', 6, 3, NULL);
INSERT INTO `study_answer` VALUES (29, '直接回答1', '2025-09-25 10:06:36.732737', 0, b'1', 0, '2025-10-10 09:44:42.019905', 6, 3, NULL);
INSERT INTO `study_answer` VALUES (46, 'adaadsas', '2025-10-06 07:45:02.523518', 0, b'0', 1, '2025-10-06 07:45:08.369627', 4, 3, NULL);
INSERT INTO `study_answer` VALUES (47, '@asss adadasd', '2025-10-06 07:45:07.003652', 0, b'0', 0, '2025-10-06 07:45:07.003652', 4, 3, 46);
INSERT INTO `study_answer` VALUES (48, 'adaada', '2025-10-06 07:46:34.117551', 0, b'0', 0, '2025-10-11 09:55:23.327889', 7, 3, NULL);
INSERT INTO `study_answer` VALUES (50, 'hahaha', '2025-10-07 06:55:03.100258', 0, b'0', 1, '2025-10-08 08:04:39.177606', 8, 3, NULL);
INSERT INTO `study_answer` VALUES (52, 'hahah', '2025-10-07 07:11:13.937842', 0, b'1', 0, '2025-10-11 11:23:53.762773', 7, 3, NULL);
INSERT INTO `study_answer` VALUES (53, '好的我老回答', '2025-10-10 09:43:32.388635', 0, b'0', 0, '2025-10-11 10:39:49.502155', 7, 6, NULL);
INSERT INTO `study_answer` VALUES (54, '@asss aaaaaa', '2025-10-11 17:13:13.575933', 0, b'0', 0, '2025-10-11 17:13:13.575933', 8, 1, 50);
COMMIT;

-- ----------------------------
-- Table structure for study_answer_like
-- ----------------------------
DROP TABLE IF EXISTS `study_answer_like`;
CREATE TABLE `study_answer_like` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) DEFAULT NULL,
  `answer_id` bigint NOT NULL,
  `user_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UKg5hqg76y5hh08hj0tpfnn2w7x` (`answer_id`,`user_id`),
  KEY `FKjy9jxsiatwnxepbnb67spfpcm` (`user_id`),
  CONSTRAINT `FKappw2lxbknwljt2kvlaefimnr` FOREIGN KEY (`answer_id`) REFERENCES `study_answer` (`id`),
  CONSTRAINT `FKjy9jxsiatwnxepbnb67spfpcm` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for study_category
-- ----------------------------
DROP TABLE IF EXISTS `study_category`;
CREATE TABLE `study_category` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `description` varchar(500) DEFAULT NULL,
  `is_active` bit(1) DEFAULT NULL,
  `created_at` datetime(6) DEFAULT NULL,
  `updated_at` datetime(6) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of study_category
-- ----------------------------
BEGIN;
INSERT INTO `study_category` VALUES (1, '开发安全', '开发安全学习', b'1', '2025-10-08 08:16:58.492988', NULL);
INSERT INTO `study_category` VALUES (2, 'AI类', '啊哈哈哈', b'1', '2025-10-08 08:16:58.492988', NULL);
COMMIT;

-- ----------------------------
-- Table structure for study_course
-- ----------------------------
DROP TABLE IF EXISTS `study_course`;
CREATE TABLE `study_course` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `category` varchar(255) DEFAULT NULL,
  `cover_image` varchar(255) DEFAULT NULL,
  `create_time` datetime(6) DEFAULT NULL,
  `description` varchar(1000) DEFAULT NULL,
  `difficulty_level` varchar(255) DEFAULT NULL,
  `estimated_duration` int DEFAULT NULL,
  `publish_time` datetime(6) DEFAULT NULL,
  `status` varchar(255) DEFAULT NULL,
  `subcategory` varchar(255) DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `creator_id` bigint DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK8y1q9p6l29s81ogef4j4om2sl` (`creator_id`),
  CONSTRAINT `FK8y1q9p6l29s81ogef4j4om2sl` FOREIGN KEY (`creator_id`) REFERENCES `sys_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of study_course
-- ----------------------------
BEGIN;
INSERT INTO `study_course` VALUES (4, '开发安全', 'http://localhost:8080/api/files/download/course_cover_2a6cad2a-2b07-4b14-9014-da229490079b.jpg', '2025-09-08 16:33:26.683909', 'AI学习课程', NULL, NULL, '2025-09-12 14:58:53.481024', 'ACTIVE', NULL, 'AI学习', '2025-09-12 14:58:53.481559', 1);
INSERT INTO `study_course` VALUES (5, '开发安全', '/api/files/download/course_cover_ea425cfe-1e1b-4bcc-ad53-c0522807ea46.jpg', '2025-09-08 16:53:47.203844', '', NULL, NULL, NULL, 'INACTIVE', NULL, '课程2', '2025-09-10 10:16:57.496917', 1);
INSERT INTO `study_course` VALUES (6, '开发安全', 'http://localhost:8080/api/files/download/course_cover_8e1c81d3-e42b-452d-a789-b211d46a14ab.jpg', '2025-09-12 16:06:45.212189', 'Python学习', NULL, NULL, '2025-09-12 16:52:46.979247', 'ACTIVE', NULL, 'Python', '2025-09-12 16:52:46.980206', 2);
INSERT INTO `study_course` VALUES (7, '开发安全', 'http://localhost:8080/api/files/download/course_cover_c529f971-c7f3-412c-bba9-fab08cda24c5.jpg', '2025-09-26 09:42:10.233128', '啊啊啊啊啊啊啊', NULL, NULL, NULL, NULL, NULL, 'JAVA开发', '2025-09-26 09:42:10.233128', 2);
COMMIT;

-- ----------------------------
-- Table structure for study_lesson
-- ----------------------------
DROP TABLE IF EXISTS `study_lesson`;
CREATE TABLE `study_lesson` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `content` varchar(2000) DEFAULT NULL,
  `create_time` datetime(6) DEFAULT NULL,
  `display_order` int DEFAULT NULL,
  `document_url` varchar(255) DEFAULT NULL,
  `estimated_duration` int DEFAULT NULL,
  `lesson_type` varchar(255) DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `video_url` varchar(255) DEFAULT NULL,
  `module_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FKak00b9i3y0d01a7n3xqjxvesu` (`module_id`),
  CONSTRAINT `FKak00b9i3y0d01a7n3xqjxvesu` FOREIGN KEY (`module_id`) REFERENCES `study_module` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for study_module
-- ----------------------------
DROP TABLE IF EXISTS `study_module`;
CREATE TABLE `study_module` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) DEFAULT NULL,
  `description` varchar(500) DEFAULT NULL,
  `display_order` int DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `course_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK3tumj77omkpq1hj3j4cnktk5m` (`course_id`),
  CONSTRAINT `FK3tumj77omkpq1hj3j4cnktk5m` FOREIGN KEY (`course_id`) REFERENCES `study_course` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for study_points_transaction
-- ----------------------------
DROP TABLE IF EXISTS `study_points_transaction`;
CREATE TABLE `study_points_transaction` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `description` varchar(255) DEFAULT NULL,
  `points` int DEFAULT NULL,
  `reference_id` bigint DEFAULT NULL,
  `transaction_time` datetime(6) DEFAULT NULL,
  `transaction_type` varchar(255) DEFAULT NULL,
  `user_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FKf8i1tuqa0yf1dy6ssja4y1xpn` (`user_id`),
  CONSTRAINT `FKf8i1tuqa0yf1dy6ssja4y1xpn` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of study_points_transaction
-- ----------------------------
BEGIN;
INSERT INTO `study_points_transaction` VALUES (1, 'aaa', 10, NULL, '2025-10-09 09:31:32.173854', 'ADMIN_ADJUST', 3);
COMMIT;

-- ----------------------------
-- Table structure for study_question
-- ----------------------------
DROP TABLE IF EXISTS `study_question`;
CREATE TABLE `study_question` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `answer_count` int DEFAULT NULL,
  `content` varchar(2000) DEFAULT NULL,
  `create_time` datetime(6) DEFAULT NULL,
  `lesson_id` bigint DEFAULT NULL,
  `like_count` int DEFAULT NULL,
  `status` varchar(255) DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `view_count` int DEFAULT NULL,
  `course_id` bigint DEFAULT NULL,
  `user_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FKnmr7j8quie1xa0vi36i4ytywy` (`course_id`),
  KEY `FKemau847ive2abrwfvhj89wnlf` (`user_id`),
  CONSTRAINT `FKemau847ive2abrwfvhj89wnlf` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`),
  CONSTRAINT `FKnmr7j8quie1xa0vi36i4ytywy` FOREIGN KEY (`course_id`) REFERENCES `study_course` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of study_question
-- ----------------------------
BEGIN;
INSERT INTO `study_question` VALUES (4, 2, '啊啊啊啊啊啊啊', '2025-09-24 09:52:21.199447', 1, 0, 'OPEN', '测试问题三', '2025-10-10 09:45:03.685448', 6, NULL, 3);
INSERT INTO `study_question` VALUES (6, 4, '啊阿萨大大撒大声地', '2025-09-24 09:54:49.930993', NULL, 6, 'RESOLVED', '啊啊啊啊大大是的', '2025-10-11 10:39:35.996576', 105, NULL, 3);
INSERT INTO `study_question` VALUES (7, 3, 'adadadasd', '2025-10-06 07:45:56.322450', NULL, 0, 'RESOLVED', 'aaaa2', '2025-10-11 11:24:03.006501', 11, NULL, 2);
INSERT INTO `study_question` VALUES (8, 2, 'aaaaaa', '2025-10-06 07:46:06.029546', 1, 0, 'OPEN', 'wwww3', '2025-10-11 17:13:05.533498', 6, 4, 2);
COMMIT;

-- ----------------------------
-- Table structure for study_question_like
-- ----------------------------
DROP TABLE IF EXISTS `study_question_like`;
CREATE TABLE `study_question_like` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) DEFAULT NULL,
  `question_id` bigint NOT NULL,
  `user_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UKja5sen3g0q5anthol4w4br9sj` (`question_id`,`user_id`),
  KEY `FK14kul2evktp99ol88flxxoxis` (`user_id`),
  CONSTRAINT `FK14kul2evktp99ol88flxxoxis` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`),
  CONSTRAINT `FK8l3svov3wo63pfgo0txllkt04` FOREIGN KEY (`question_id`) REFERENCES `study_question` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for sys_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_permission`;
CREATE TABLE `sys_permission` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `action` varchar(255) NOT NULL,
  `create_time` datetime(6) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `permission_code` varchar(255) NOT NULL,
  `permission_name` varchar(255) NOT NULL,
  `resource_type` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UKeul7rmgx0nfvykgb9vmh0cgd8` (`permission_code`),
  UNIQUE KEY `UKnkxr1fufl2nchmqdij2qy2yrn` (`permission_name`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of sys_permission
-- ----------------------------
BEGIN;
INSERT INTO `sys_permission` VALUES (1, 'CREATE', '2025-09-05 17:23:46.686834', '创建用户', 'USER_CREATE', 'USER_CREATE', '用户管理');
INSERT INTO `sys_permission` VALUES (2, 'READ', '2025-09-05 17:23:46.733566', '查看用户', 'USER_READ', 'USER_READ', '用户管理');
INSERT INTO `sys_permission` VALUES (3, 'UPDATE', '2025-09-05 17:23:46.736963', '修改用户', 'USER_UPDATE', 'USER_UPDATE', '用户管理');
INSERT INTO `sys_permission` VALUES (4, 'DELETE', '2025-09-05 17:23:46.740821', '删除用户', 'USER_DELETE', 'USER_DELETE', '用户管理');
INSERT INTO `sys_permission` VALUES (5, 'CREATE', '2025-09-05 17:23:46.744378', '创建角色', 'ROLE_CREATE', 'ROLE_CREATE', '角色管理');
INSERT INTO `sys_permission` VALUES (6, 'READ', '2025-09-05 17:23:46.747171', '查看角色', 'ROLE_READ', 'ROLE_READ', '角色管理');
INSERT INTO `sys_permission` VALUES (7, 'UPDATE', '2025-09-05 17:23:46.750060', '修改角色', 'ROLE_UPDATE', 'ROLE_UPDATE', '角色管理');
INSERT INTO `sys_permission` VALUES (8, 'DELETE', '2025-09-05 17:23:46.752807', '删除角色', 'ROLE_DELETE', 'ROLE_DELETE', '角色管理');
INSERT INTO `sys_permission` VALUES (9, 'CREATE', '2025-09-05 17:23:46.755411', '创建权限', 'PERMISSION_CREATE', 'PERMISSION_CREATE', '权限管理');
INSERT INTO `sys_permission` VALUES (10, 'READ', '2025-09-05 17:23:46.758371', '查看权限', 'PERMISSION_READ', 'PERMISSION_READ', '权限管理');
INSERT INTO `sys_permission` VALUES (11, 'UPDATE', '2025-09-05 17:23:46.761019', '修改权限', 'PERMISSION_UPDATE', 'PERMISSION_UPDATE', '权限管理');
INSERT INTO `sys_permission` VALUES (12, 'DELETE', '2025-09-05 17:23:46.763894', '删除权限', 'PERMISSION_DELETE', 'PERMISSION_DELETE', '权限管理');
INSERT INTO `sys_permission` VALUES (13, 'CREATE', '2025-09-05 17:23:46.766675', '创建课程', 'COURSE_CREATE', 'COURSE_CREATE', '课程管理');
INSERT INTO `sys_permission` VALUES (14, 'READ', '2025-09-05 17:23:46.769304', '查看课程', 'COURSE_READ', 'COURSE_READ', '课程管理');
INSERT INTO `sys_permission` VALUES (15, 'UPDATE', '2025-09-05 17:23:46.772331', '更新课程', 'COURSE_UPDATE', 'COURSE_UPDATE', '课程管理');
INSERT INTO `sys_permission` VALUES (16, 'DELETE', '2025-09-05 17:23:46.775401', '删除课程', 'COURSE_DELETE', 'COURSE_DELETE', '课程管理');
INSERT INTO `sys_permission` VALUES (17, 'UPDATE', '2025-09-05 17:23:46.778158', '管理课程分类', 'COURSE_CATEGORY_MANAGE', 'COURSE_CATEGORY_MANAGE', '课程管理');
INSERT INTO `sys_permission` VALUES (18, 'UPDATE', '2025-09-05 17:23:46.780645', '管理课程标签', 'COURSE_TAG_MANAGE', 'COURSE_TAG_MANAGE', '课程管理');
INSERT INTO `sys_permission` VALUES (19, 'CREATE', '2025-09-05 17:23:46.783328', '上传课程视频', 'COURSE_VIDEO_UPLOAD', 'COURSE_VIDEO_UPLOAD', '课程管理');
INSERT INTO `sys_permission` VALUES (20, 'UPDATE', '2025-09-05 17:23:46.785713', '控制视频访问权限', 'COURSE_VIDEO_ACCESS_CONTROL', 'COURSE_VIDEO_ACCESS_CONTROL', '课程管理');
INSERT INTO `sys_permission` VALUES (21, 'UPDATE', '2025-09-05 17:23:46.788555', '审核视频材料', 'COURSE_VIDEO_APPROVAL', 'COURSE_VIDEO_APPROVAL', '课程管理');
COMMIT;

-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) DEFAULT NULL,
  `role_description` varchar(255) DEFAULT NULL,
  `role_name` varchar(255) NOT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UK7kwex0745q0eycdwi4d2yihi3` (`role_name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of sys_role
-- ----------------------------
BEGIN;
INSERT INTO `sys_role` VALUES (1, '2025-09-04 15:25:51.198174', '系统管理员', 'ADMIN', '2025-09-04 15:25:51.198174');
INSERT INTO `sys_role` VALUES (2, '2025-09-04 15:25:51.252770', '讲师', 'LECTURER', '2025-09-04 15:25:51.252770');
INSERT INTO `sys_role` VALUES (3, '2025-09-04 15:25:51.255915', '学生', 'STUDENT', '2025-09-04 15:25:51.255915');
INSERT INTO `sys_role` VALUES (4, '2025-09-04 15:25:51.260424', '审计员', 'AUDITOR', '2025-09-04 15:25:51.260424');
COMMIT;

-- ----------------------------
-- Table structure for sys_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_permission`;
CREATE TABLE `sys_role_permission` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) DEFAULT NULL,
  `permission_id` bigint NOT NULL,
  `role_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UKsait308gqqfqha9pd9vfkfdc8` (`role_id`,`permission_id`),
  KEY `FKomxrs8a388bknvhjokh440waq` (`permission_id`),
  CONSTRAINT `FK9q28ewrhntqeipl1t04kh1be7` FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`id`),
  CONSTRAINT `FKomxrs8a388bknvhjokh440waq` FOREIGN KEY (`permission_id`) REFERENCES `sys_permission` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of sys_role_permission
-- ----------------------------
BEGIN;
INSERT INTO `sys_role_permission` VALUES (1, '2025-09-05 17:23:46.919338', 1, 1);
INSERT INTO `sys_role_permission` VALUES (2, '2025-09-05 17:23:46.931254', 2, 1);
INSERT INTO `sys_role_permission` VALUES (3, '2025-09-05 17:23:46.940765', 3, 1);
INSERT INTO `sys_role_permission` VALUES (4, '2025-09-05 17:23:46.950755', 4, 1);
INSERT INTO `sys_role_permission` VALUES (5, '2025-09-05 17:23:46.960477', 5, 1);
INSERT INTO `sys_role_permission` VALUES (6, '2025-09-05 17:23:46.971658', 6, 1);
INSERT INTO `sys_role_permission` VALUES (7, '2025-09-05 17:23:46.980536', 7, 1);
INSERT INTO `sys_role_permission` VALUES (8, '2025-09-05 17:23:46.990051', 8, 1);
INSERT INTO `sys_role_permission` VALUES (9, '2025-09-05 17:23:46.998709', 9, 1);
INSERT INTO `sys_role_permission` VALUES (10, '2025-09-05 17:23:47.007540', 10, 1);
INSERT INTO `sys_role_permission` VALUES (11, '2025-09-05 17:23:47.016852', 11, 1);
INSERT INTO `sys_role_permission` VALUES (12, '2025-09-05 17:23:47.025627', 12, 1);
INSERT INTO `sys_role_permission` VALUES (13, '2025-09-05 17:23:47.035345', 13, 1);
INSERT INTO `sys_role_permission` VALUES (14, '2025-09-05 17:23:47.044223', 14, 1);
INSERT INTO `sys_role_permission` VALUES (15, '2025-09-05 17:23:47.053190', 15, 1);
INSERT INTO `sys_role_permission` VALUES (16, '2025-09-05 17:23:47.061162', 16, 1);
INSERT INTO `sys_role_permission` VALUES (17, '2025-09-05 17:23:47.069780', 17, 1);
INSERT INTO `sys_role_permission` VALUES (18, '2025-09-05 17:23:47.080815', 18, 1);
INSERT INTO `sys_role_permission` VALUES (19, '2025-09-05 17:23:47.090601', 19, 1);
INSERT INTO `sys_role_permission` VALUES (20, '2025-09-05 17:23:47.102343', 20, 1);
INSERT INTO `sys_role_permission` VALUES (21, '2025-09-05 17:23:47.112569', 21, 1);
INSERT INTO `sys_role_permission` VALUES (22, '2025-09-05 17:23:47.166437', 13, 2);
INSERT INTO `sys_role_permission` VALUES (23, '2025-09-05 17:23:47.176888', 14, 2);
INSERT INTO `sys_role_permission` VALUES (24, '2025-09-05 17:23:47.185145', 15, 2);
INSERT INTO `sys_role_permission` VALUES (25, '2025-09-05 17:23:47.194253', 19, 2);
INSERT INTO `sys_role_permission` VALUES (26, '2025-09-05 17:23:47.202899', 20, 2);
COMMIT;

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `avatar` varchar(255) DEFAULT NULL,
  `create_time` datetime(6) DEFAULT NULL,
  `department` varchar(255) DEFAULT NULL,
  `lock_time` datetime(6) DEFAULT NULL,
  `login_fail_count` int DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `phone` varchar(255) DEFAULT NULL,
  `role` varchar(255) NOT NULL,
  `status` int NOT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `username` varchar(255) NOT NULL,
  `bio` varchar(500) DEFAULT NULL,
  `birth_date` datetime(6) DEFAULT NULL,
  `gender` varchar(255) DEFAULT NULL,
  `nickname` varchar(255) DEFAULT NULL,
  `study_level` int DEFAULT NULL,
  `study_points` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UK51bvuyvihefoh4kp5syh2jpi4` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of sys_user
-- ----------------------------
BEGIN;
INSERT INTO `sys_user` VALUES (1, 'uploads/avatars/1_bf949cde-9e8e-48b2-861e-1e987e1cd8fb.jpg', '2025-09-04 15:25:51.412171', 'IT部', NULL, 0, '管理员', '$2a$10$frvpLTZl2pKintIAnVLBCO8t4wCfcqfJg68sOr34TghOxZipUEnPK', '12345678900', 'ADMIN', 1, '2025-10-05 17:43:45.281625', 'admin', '', NULL, '', '', NULL, NULL);
INSERT INTO `sys_user` VALUES (2, NULL, '2025-09-12 15:18:57.293003', 'AI', NULL, 0, 'hha', '$2a$10$uI1WOTrAw0VUsbEDIEyXseEhXolUc7iwH9R7/3R11j4JRiIAgXG1a', '198776542623', 'LECTURER', 1, '2025-09-12 15:25:56.584017', 'test1', NULL, NULL, NULL, NULL, 1, 0);
INSERT INTO `sys_user` VALUES (3, NULL, '2025-09-12 15:22:33.620672', NULL, NULL, 0, 'asss', '$2a$10$qZTlmcmEjfSS6R6s2bkIm.V2Ihbz.kdKZNyWJ8cb1/P9OCvl4ySvW', '17789876567', 'STUDENT', 1, '2025-10-09 09:31:32.230308', 'test2', '', NULL, 'MALE', '', 1, 10);
INSERT INTO `sys_user` VALUES (6, NULL, '2025-10-10 09:39:51.438818', '啊啊啊啊', NULL, 0, '测试用户', '$2a$10$ynqR1oIZJeaiozz9kPVyYOsCC4efSIuHWObslOReGVwX/O/jfGzJ.', '17786654456', 'STUDENT', 1, '2025-10-10 09:39:51.438818', 'test3', NULL, NULL, NULL, NULL, 1, 0);
COMMIT;

-- ----------------------------
-- Table structure for sys_user_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) DEFAULT NULL,
  `role_id` bigint NOT NULL,
  `user_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UKmjo3l593cr1835oo1asuch8u` (`user_id`,`role_id`),
  KEY `FKhh52n8vd4ny9ff4x9fb8v65qx` (`role_id`),
  CONSTRAINT `FKb40xxfch70f5qnyfw8yme1n1s` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`),
  CONSTRAINT `FKhh52n8vd4ny9ff4x9fb8v65qx` FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of sys_user_role
-- ----------------------------
BEGIN;
INSERT INTO `sys_user_role` VALUES (1, '2025-09-04 15:25:51.446307', 1, 1);
INSERT INTO `sys_user_role` VALUES (2, '2025-09-12 15:25:56.567517', 2, 2);
INSERT INTO `sys_user_role` VALUES (4, '2025-09-12 15:27:46.444164', 3, 3);
INSERT INTO `sys_user_role` VALUES (5, '2025-10-10 09:39:51.495003', 3, 6);
COMMIT;

-- ----------------------------
-- Table structure for user_achievement
-- ----------------------------
DROP TABLE IF EXISTS `user_achievement`;
CREATE TABLE `user_achievement` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `achievement_name` varchar(255) DEFAULT NULL,
  `achievement_type` varchar(255) DEFAULT NULL,
  `badge_icon` varchar(255) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `earned_time` datetime(6) DEFAULT NULL,
  `user_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK18kt6a25md0u92y1bdje9v87i` (`user_id`),
  CONSTRAINT `FK18kt6a25md0u92y1bdje9v87i` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for user_course_enrollment
-- ----------------------------
DROP TABLE IF EXISTS `user_course_enrollment`;
CREATE TABLE `user_course_enrollment` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `completed_lessons` int DEFAULT NULL,
  `completion_date` datetime(6) DEFAULT NULL,
  `enrollment_date` datetime(6) DEFAULT NULL,
  `enrollment_status` varchar(255) DEFAULT NULL,
  `progress_percentage` int DEFAULT NULL,
  `total_lessons` int DEFAULT NULL,
  `course_id` bigint NOT NULL,
  `user_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UKd2pwpkcs2kxcsn1ynb59rskb2` (`user_id`,`course_id`),
  KEY `FKgov9hi8yqcbb5olruhma4cfsg` (`course_id`),
  CONSTRAINT `FKew41fyjjxraksfuybrtdyi83v` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`),
  CONSTRAINT `FKgov9hi8yqcbb5olruhma4cfsg` FOREIGN KEY (`course_id`) REFERENCES `study_course` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for user_lesson_progress
-- ----------------------------
DROP TABLE IF EXISTS `user_lesson_progress`;
CREATE TABLE `user_lesson_progress` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `completion_time` datetime(6) DEFAULT NULL,
  `last_access_time` datetime(6) DEFAULT NULL,
  `start_time` datetime(6) DEFAULT NULL,
  `status` varchar(255) DEFAULT NULL,
  `total_duration` int DEFAULT NULL,
  `viewed_duration` int DEFAULT NULL,
  `lesson_id` bigint NOT NULL,
  `user_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UKqtk0f3koh1fjn49jfeu9mdcy0` (`user_id`,`lesson_id`),
  KEY `FKh4cbsde4sksiocrwn7r8pqtca` (`lesson_id`),
  CONSTRAINT `FK32cuxmjlea7t97xi2uwnsvjpb` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`),
  CONSTRAINT `FKh4cbsde4sksiocrwn7r8pqtca` FOREIGN KEY (`lesson_id`) REFERENCES `study_lesson` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for video_access_control
-- ----------------------------
DROP TABLE IF EXISTS `video_access_control`;
CREATE TABLE `video_access_control` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `can_view` bit(1) DEFAULT NULL,
  `created_at` datetime(6) DEFAULT NULL,
  `lecturer_id` bigint NOT NULL,
  `student_id` bigint NOT NULL,
  `video_id` bigint NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK981fghsx4bj5vepgq5r01yafn` (`lecturer_id`),
  KEY `FKscopa2p66fitj3pbxhy5q87j1` (`student_id`),
  KEY `FKjw83r2o9xadswpaj95fmwbh32` (`video_id`),
  CONSTRAINT `FK981fghsx4bj5vepgq5r01yafn` FOREIGN KEY (`lecturer_id`) REFERENCES `sys_user` (`id`),
  CONSTRAINT `FKjw83r2o9xadswpaj95fmwbh32` FOREIGN KEY (`video_id`) REFERENCES `study_lesson` (`id`),
  CONSTRAINT `FKscopa2p66fitj3pbxhy5q87j1` FOREIGN KEY (`student_id`) REFERENCES `sys_user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Table structure for videos
-- ----------------------------
DROP TABLE IF EXISTS `videos`;
CREATE TABLE `videos` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `course_id` bigint DEFAULT NULL,
  `description` varchar(1000) DEFAULT NULL,
  `file_name` varchar(255) NOT NULL,
  `file_path` varchar(255) NOT NULL,
  `file_size` bigint DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `url` varchar(255) NOT NULL,
  `approved_by` bigint DEFAULT NULL,
  `approved_time` datetime(6) DEFAULT NULL,
  `created_by` bigint DEFAULT NULL,
  `created_time` datetime(6) DEFAULT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'PENDING',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3;

-- ----------------------------
-- Records of videos
-- ----------------------------
BEGIN;
INSERT INTO `videos` VALUES (1, 4, '视频学习', '127d42c8-6a83-4266-9b4a-84e27163c07e.mp4', '/Users/lhc/Code/AICode/ClaudeCode/study-management-system/uploads/videos/course_4/127d42c8-6a83-4266-9b4a-84e27163c07e.mp4', 4866802, '第一课', '/api/study/videos/download/4/127d42c8-6a83-4266-9b4a-84e27163c07e.mp4', 1, '2025-09-12 13:53:37.840232', NULL, NULL, 'APPROVED');
INSERT INTO `videos` VALUES (2, 6, 'Python学习', 'eeb834d7-01a7-4b65-bbe5-02313fe576c4.mp4', '/Users/lhc/Code/AICode/ClaudeCode/study-management-system/uploads/videos/course_6/eeb834d7-01a7-4b65-bbe5-02313fe576c4.mp4', 8204321, 'Python第一课', '/api/study/videos/download/6/eeb834d7-01a7-4b65-bbe5-02313fe576c4.mp4', 1, '2025-09-15 11:05:58.378616', 2, '2025-09-15 11:05:31.515596', 'APPROVED');
INSERT INTO `videos` VALUES (4, 6, '没有任何问题', '5c591538-968f-4f26-96ec-a41bde463a7e.mp4', '/Users/lhc/Code/AICode/ClaudeCode/study-management-system/uploads/videos/course_6/5c591538-968f-4f26-96ec-a41bde463a7e.mp4', 4866802, '第二节课程', '/api/study/videos/download/6/5c591538-968f-4f26-96ec-a41bde463a7e.mp4', 1, '2025-09-26 09:43:23.980227', 2, '2025-09-26 09:42:54.820535', 'APPROVED');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
